<?php
/**
*	系统里默认的系统日志模块的
*/
namespace Rainrock\Framework\Module;


use Rainrock\Framework\kernel\core\ModuleInfo;
use Rainrock\Framework\kernel\core\ModuleFields;

class SystaskModuleInfo extends ModuleInfo{
	
	protected function initModule(){
		 $this->setName('计划任务');
		 $this->setNum('syslog');
		 
		 $this->addFields(ModuleFields::get('name')
			->setName('任务名称')
			->setLen(50)
			->setType('varchar')
		 );
		 
		 
		 $this->addFields(ModuleFields::get('runtime')
			->setName('运行时间')
			->setLen(100)
			->setType('varchar')
		 );
		 
		 $this->addFields(ModuleFields::get('runurl')
			->setName('运行地址')
			->setLen(100)
			->setAlign('left')
			->setType('varchar')
		 );
		 
	
		 $this->addFields(ModuleFields::get('lastdt')
			->setName('最后运行')
			->setType('datetime')
		 );
		
		 $this->addFields(ModuleFields::get('result')
			->setName('运行结果')
			->setLen(500)
			->setType('varchar')
		 );
		 
		 $this->addFields(ModuleFields::get('status')
			->setName('状态')
			->setLen(1)
			->setDev(1)
			->setIspx(1)
			->setData('0|停用|gray,1|启用|green')
			->setFieldstype('select')
			->setType('tinyint')
		 );
		 

	}
	
	/**
	*	添加默认的计划任务
	*/
	public function addTask($name, $runurl, $runtime)
	{
		$where 	= "`name`='$name'";
		$ors 	= $this->model->getone($where);
		if(!$ors){
			$this->model->insert(array(
				'name' 	 => $name,
				'runurl' => $runurl,
				'runtime' => $runtime,
			));
		}
	}
}